package com.zpxt.zpxt;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
public class HelloController {

    @Autowired
    private JavaMailSender javaMailSender;
    @Value("${spring.mail.username}")
    private String username;

    @RequestMapping("/hello")
    public String hello() {
        return "hello,this is a springboot demo";
    }

    @RequestMapping("/test")
    public void test(){
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(username);
        message.setTo("503722728@qq.com");
        message.setSubject("标题：测试标题");
        message.setText("测试内容部份");
        javaMailSender.send(message);
    }
}
